package com.evenmo.string;

import org.junit.Test;

/**
 * 冒泡排序测试
 */
public class BubbleSort {

    @Test
    public void bubbleSort(){
        int[] arr={99,55,5,9,2,5,3,1,8};

        for (int i=0;i<arr.length-1;i++){

            for (int j=0;j<arr.length-1-i;j++){
                if(arr[j]>arr[j+1]){
                    arr[j]=arr[j+1]^arr[j];
                    arr[j+1]=arr[j]^arr[j+1];
                    arr[j]=arr[j]^arr[j+1];
                }
            }
        }

        for (int i : arr) {
            System.out.println(i);
        }


    }
}
